﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text.RegularExpressions;

[Serializable]
public class abItem
{
    private String _abValue;
    private String _abText;
    private String _abEngText; 
    
    public abItem()
    {
    }

    public String abEngText
    {
        get
        {
            return _abEngText;
        }
        set
        {
            _abEngText = value;
        }
    }

    public String abText 
    {
        get
        {
            return _abText;
        }
        set
        {
            _abText = value;
        }
    }

    public String abValue
    {
        get
        {
            return _abValue;
        }
        set
        {
            _abValue = value;
        }
    }

    public static List<abItem> SetAbArrayList()
    {
        List<abItem> list  = new List<abItem>();
        //abItem

        abItem f = new abItem();
        f.abText = "а";
        f._abEngText= "a";
        f.abValue = "1";
        list.Add(f);
        f = new abItem();
        f.abText = "б";
        f._abEngText = "b";
        f.abValue = "2";
        list.Add(f);
        f = new abItem();
        f.abText = "в";
        f._abEngText = "w";
        f.abValue = "3";
        list.Add(f);
        f = new abItem();
        f.abText = "г";
        f._abEngText = "g";
        f.abValue = "4";
        list.Add(f);
        f = new abItem();
        f.abText = "д";
        f._abEngText = "d";
        f.abValue = "5";
        list.Add(f);

        f = new abItem();
        f.abText = "е";
        f._abEngText = "e";
        f.abValue = "6";
        list.Add(f);

        f = new abItem();
        f.abText = "ж";
        f._abEngText = "j";
        f.abValue = "7";
        list.Add(f);

        f = new abItem();
        f.abText = "з";
        f._abEngText = "z";
        f.abValue = "8";
        list.Add(f);
        f = new abItem();
        f.abText = "и";
        f._abEngText = "i";
        f.abValue = "9";
        list.Add(f);

        f = new abItem();
        f.abText = "к";
        f._abEngText = "k";
        f.abValue = "11";
        list.Add(f);

        f = new abItem();
        f.abText = "л";
        f._abEngText = "l";
        f.abValue = "12";
        list.Add(f);

        f = new abItem();
        f.abText = "м";
        f._abEngText = "m";
        f.abValue = "13";
        list.Add(f);

        f = new abItem();
        f.abText = "н";
        f._abEngText = "n";
        f.abValue = "14";
        list.Add(f);

        f = new abItem();
        f.abText = "о";
        f._abEngText = "o";
        f.abValue = "15";
        list.Add(f);

        f = new abItem();
        f.abText = "п";
        f._abEngText = "p";
        f.abValue = "16";
        list.Add(f);

        f = new abItem();
        f.abText = "р";
        f._abEngText= "r";
        f.abValue = "17";
        list.Add(f);

        f = new abItem();
        f.abText = "с";
        f._abEngText = "s";
        f.abValue = "18";
        list.Add(f);

        f = new abItem();
        f.abText = "т";
        f._abEngText = "t";
        f.abValue = "19";
        list.Add(f);

        f = new abItem();
        f.abText = "у";
        f._abEngText = "u";
        f.abValue = "20";
        list.Add(f);

        f = new abItem();
        f.abText = "ф";
        f._abEngText = "f";
        f.abValue = "21";
        list.Add(f);

        f = new abItem();
        f.abText = "х";
        f._abEngText = "x";
        f.abValue = "22";
        list.Add(f);

        f = new abItem();
        f.abText = "ц";
        f._abEngText = "c";
        f.abValue = "23";
        list.Add(f);

        f = new abItem();
        f.abText = "ч";
        f._abEngText = "ch";
        f.abValue = "24";
        list.Add(f);

        f = new abItem();
        f.abText = "ш";
        f._abEngText = "sh";
        f.abValue = "25";
        list.Add(f);

        f = new abItem();
        f.abText = "э";
        f._abEngText = "je";
        f.abValue = "30";
        list.Add(f);

        f = new abItem();
        f.abText = "ю";
        f._abEngText = "ju";
        f.abValue = "31";
        list.Add(f);

        f = new abItem();
        f.abText = "я";
        f._abEngText = "ja";
        f.abValue = "32";
        list.Add(f);

        f = new abItem();
        f.abText = " ";
        f._abEngText = "_";
        f.abValue = "33";
        list.Add(f);

        return list;
    }

    }
/// <summary>
/// Summary description for ab
/// </summary>
public static class ab
{

      public static List<abItem> GetAbArrayList()
      {
          return abItem.SetAbArrayList();
      }

     public static String GetAbText(String abValue)
     {
         List<abItem> l = abItem.SetAbArrayList();
        string abChar=string.Empty;
        
         foreach(abItem i in l)
         {
             if(abValue == i.abValue)
                abChar = i.abText;
         }
        return abChar;
     }

    public static String GetAbValue(String abText)
    {
        List<abItem> l = abItem.SetAbArrayList();
        string abChar=string.Empty;

        foreach(abItem i in l)
        {
            if(abText == i.abText)
                abChar = i.abValue;
        }
        return abChar;
    }

    public static String ConvertToEnglishText(String abText)
    {

        string str = Regex.Replace(abText, "[^A-Z^a-z^а-я^А-Я^0-9^ ^-]", "");
        return str.Replace(" ", "-");

        //string sRetStr=string.Empty;
        //List<abItem> l = abItem.SetAbArrayList();
        //Regex regEx = new Regex("[a-zA-Z]");

        //foreach (char s in abText.ToLower().ToCharArray())
        //{
        //    if (regEx.Match(s.ToString()).Captures.Count==0)
        //    {
        //        foreach (abItem i in l)
        //        {
        //            if (s.ToString() == i.abText)
        //                sRetStr += i.abEngText;
        //        }
        //    }
        //    else
        //        sRetStr += s.ToString();
        //}
        //return sRetStr;
    }
}
